<template>
  <header background-color="#373D41">
    <div class="l-content">
      <el-button plain icon="el-icon-menu" size="mini"></el-button>
      <h3 style="color:#fff">&nbsp;&nbsp;Easy-Shop管理系统</h3>
    </div>
    <div class="r-content">
      <el-dropdown trigger="click" size="mini" @command="handleCommand">
        <span class="el-dropdown-link">
          <img :src="userImg" class="user"/>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
export default {
  name: 'CommenHeader',
  data () {
    return {
      userImg: require('../assets/user.png'),
    }
  },
  methods: {
    handleCommand (command) {
      if (command == 'logout') {
        window.sessionStorage.clear()
        this.$message('退出成功！ ')
        this.$router.push('/login')
      }
    }
  }
}
</script>

<style scoped>
header {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-between;
}

.l-content {
  display: flex;
  align-items: center;

}

el-button {
  margin-right: 20px
}

.user {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
</style>
